package com.woniuxy.provider;

import com.woniuxy.entity.Address;
import org.apache.ibatis.jdbc.SQL;

public class AddressProvider {
    public String update(Address address){
        return new SQL(){{
            UPDATE("gfr_address");
            if (address.getPhone() !=null && address.getPhone().length() != 0) {
                SET("addr_phone+'"+address.getPhone()+"'");
            }
            if (address.getProvince() != null && address.getProvince().length() != 0) {
                SET("addr_province+'"+address.getProvince()+"'");
            }
            if (address.getCity() != null && address.getCity().length() != 0) {
                SET("addr_city+'"+address.getCity()+"'");
            }
            if (address.getDistrict() !=null && address.getDistrict().length() != 0) {
                SET("addr_district+'"+address.getDistrict() + "'");
            }
            if (address.getAddress() !=null && address.getAddress().length() !=0) {
                SET("address+'"+address.getAddress()+"'");
            }
            if (address.getPerson() != null && address.getPerson().length() != 0) {
                SET("person+'"+address.getPerson()+"'");
            }
            WHERE("id="+address.getId());
        }}.toString();
    }
}
